#include "atomic.h"
#include <atomic>

atomic<bool> x;
atomic<bool> y;
atomic<int> z;

void write_x() {
	x.store(true, memory_order_relaxed);
}

void write_y() {
	y.store(true, memory_order_relaxed);
}

void read_x_then_y() {
	while(!x.load(memory_order_relaxed));
	if (y.load(memory_order_relaxed)) {
		z++;
	}
}

void read_y_then_x() {
	while(!y.load(memory_order_relaxed));
	if (x.load(memory_order_relaxed)) {
		z++;
	}
}

